package com.woniu.product.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.woniu.product.pojo.ProductComment;
import com.woniu.product.entity.dto.ReplyDTO;
import com.woniu.product.pojo.vo.ProductCommentVo;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 商品评价表 Mapper 接口
 * </p>
 *
 * @author LiFangyu
 * @since 2023-02-15
 */
public interface ProductCommentMapper extends BaseMapper<ProductCommentVo> {

    @Select("select tp.product_id,tp.user_id,tp.title,tp.content from t_product_comment tp where tp.product_id = #{id} and tp.reply_id = \"\" ")
    List<ProductComment> listById(String id);


    @Select("select comment_id as commentId,product_id as productId,user_id as userId,title,content from t_product_comment where reply_id = #{id}")
    @ResultType(ProductCommentVo.class) // 指定返回值的类型
    List<ProductCommentVo> selectByParentId(String id);

    int saveReply(@Param("replyDTO") ReplyDTO replyDTO);

}

